package com.git.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.git.domain.AjaxJson;
import com.git.domain.DemoEntity;
import com.git.service.DemoService;

@Controller
public class DemoController {
	@Autowired
	private DemoService demoService;
	
	@RequestMapping("get")
	public ResponseEntity<AjaxJson> get(Integer id){
		DemoEntity demoEntity = this.demoService.get(id);
		return ResponseEntity.status(200).body(new AjaxJson(true,"success",demoEntity));
	}
	
	@RequestMapping("get2")
	public ResponseEntity<AjaxJson> get2(Integer id){
		DemoEntity demoEntity = this.demoService.get2(id);
		return ResponseEntity.status(200).body(new AjaxJson(true,"success",demoEntity));
	}
	
	
	@RequestMapping("update")
	public ResponseEntity<AjaxJson> update(Integer id){
		this.demoService.update(id);
		return ResponseEntity.status(200).body(new AjaxJson(true,"success",null));
	}
	
	@RequestMapping("delete")
	public ResponseEntity<AjaxJson> delete(Integer id){
		this.demoService.delete(id);
		return ResponseEntity.status(200).body(new AjaxJson(true,"success",null));
	}
	
}
